package com.clear.factory.demo;

import com.clear.factory.demo.factory.DatabaseConnection;
import com.clear.factory.demo.factory.impl.MySQLConnection;
import com.clear.factory.demo.factory.impl.OracleConnection;
import com.clear.factory.demo.factory.impl.PostgreSQLConnection;

public class DatabaseConnectionFactory {

    public static DatabaseConnection createDatabaseConnection(String databaseType){
        if (databaseType == null) {
            throw new IllegalArgumentException("Database type cannot be null.");
        }

        if (databaseType.equalsIgnoreCase("MySQL")) {
            return new MySQLConnection();
        } else if (databaseType.equalsIgnoreCase("PostgreSQL")) {
            return new PostgreSQLConnection();
        } else if (databaseType.equalsIgnoreCase("Oracle")) {
            return new OracleConnection();
        } else {
            throw new IllegalArgumentException("Invalid database type: " + databaseType);
        }
    }
}
